package org.xteam.sled.model;

import org.xteam.sled.semantic.Field;

public class AbsoluteField implements IField {
	
	private Field field;
	private int offset;
	
	public AbsoluteField(Field field, int n) {
		this.field = field;
		this.offset = n;
	}
	
	@Override
	public String name() {
		return field.name();
	}
	
	@Override
	public int fieldmax() {
		return field.fieldmax();
	}
	
	public Field field() {
		return field;
	}
	
	public int offset() {
		return offset;
	}
	
	@Override
	public int hashCode() {
		return field.hashCode() ^ offset;
	}
	
	@Override
	public boolean equals(Object o) {
		return (o instanceof AbsoluteField)
			&& ((AbsoluteField)o).field.equals(field)
			&& ((AbsoluteField)o).offset == offset;
	}
	
	@Override
	public String toString() {
		return field + "#" + offset;
	}
	
}
